<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta name="description" content="時光的个人博客" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
	  <meta name="referrer" content="no-referrer" />

      <title>Git快速入门 |  時光</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/atom.xml" title="時光" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-Git快速入门"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Git快速入门
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2022/01/22/Git%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/" class="article-date">
  <time datetime="2022-01-22T15:09:15.410Z" itemprop="datePublished">2022-01-22</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">3.5k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">12 min</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <p><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143145322-413927943.png" alt="image-20231118143145163"> <code>everything-is-local</code> </p>
<blockquote>
<p>Author：Shine</p>
<p>Version：9.0.2</p>
<p>视频教程：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Mf4y117f3?p=5">https://www.bilibili.com/video/BV1Mf4y117f3?p=5</a></p>
<p>文章来自B站博主，如有侵权联系删除</p>
</blockquote>
<p>[TOC]</p>
<h3 id="一、引言"><a href="#一、引言" class="headerlink" title="一、引言"></a>一、引言</h3><hr>
<blockquote>
<ul>
<li><p>在单人开发过程中，需要进行版本管理，以利于开发进度的控制。</p>
</li>
<li><p>在多人开发过程中，不仅需要<strong>版本管理</strong>，还需要进行<strong>多人协同控制</strong>。</p>
</li>
</ul>
</blockquote>
<h3 id="二、介绍"><a href="#二、介绍" class="headerlink" title="二、介绍"></a>二、介绍</h3><hr>
<blockquote>
<ul>
<li>Git是一个<strong>开源的分布式版本控制系统</strong>，用于敏捷高效地处理任何或小或大的项目。</li>
<li>Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。</li>
<li>官网：<a target="_blank" rel="noopener" href="https://git-scm.com/">https://git-scm.com/</a></li>
</ul>
</blockquote>
<h3 id="三、Git安装"><a href="#三、Git安装" class="headerlink" title="三、Git安装"></a>三、Git安装</h3><hr>
<h4 id="3-1-下载Git"><a href="#3-1-下载Git" class="headerlink" title="3.1 下载Git"></a>3.1 下载Git</h4><blockquote>
<p>下载Git <a target="_blank" rel="noopener" href="https://git-scm.com/downloads">https://git-scm.com/downloads</a></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">下载git</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143203621-2006321301.png" alt="image-20231118143203855"></td>
</tr>
</tbody></table>
<h4 id="3-2-安装"><a href="#3-2-安装" class="headerlink" title="3.2 安装"></a>3.2 安装</h4><blockquote>
<p>安装，除了安装位置外，其他一直下一步即可</p>
</blockquote>
<h4 id="3-3-基本配置"><a href="#3-3-基本配置" class="headerlink" title="3.3 基本配置"></a>3.3 基本配置</h4><blockquote>
<ul>
<li><p>安装后，打开git的cmd窗口 ，自报家门</p>
</li>
<li><p>如下信息会在提交代码时要使用，记录在你的每次提交中。以后才知道哪次提交是谁做的。</p>
</li>
</ul>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name &quot;Your Name&quot;  #用户名</span><br><span class="line">git config --global user.email &quot;email@example.com&quot;  #邮箱</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看信息</span></span><br><span class="line">git config -l </span><br></pre></td></tr></table></figure>

<h4 id="3-4-测试"><a href="#3-4-测试" class="headerlink" title="3.4 测试"></a>3.4 测试</h4><blockquote>
<p>测试：cmd中执行 ,查看git版本</p>
</blockquote>
<figure class="highlight cmd"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git version  </span><br></pre></td></tr></table></figure>

<h3 id="四、架构"><a href="#四、架构" class="headerlink" title="四、架构"></a>四、架构</h3><hr>
<blockquote>
<ul>
<li><p>版本库：工作区中有一个隐藏目录 <code>.git</code>，这个目录不属于工作区，而是git的 <code>版本库</code>，是git管理的所有内容 </p>
</li>
<li><p>暂存区：版本库中包含一个临时区域，保存下一步要提交的文件。</p>
</li>
<li><p>分支：版本库中包含若干分支，提交的文件存储在分支中</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">架构图</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143254796-1303010917.jpg" alt="暂存区"></td>
</tr>
</tbody></table>
<h3 id="五、仓库"><a href="#五、仓库" class="headerlink" title="五、仓库"></a>五、仓库</h3><hr>
<blockquote>
<p>对应的就是一个<a href="">目录</a>，这个目录中的所有文件被git管理起来。</p>
<p>以后会将一个<a href="">项目的根目录</a>，作为仓库。</p>
<p>仓库中的每个文件的改动 都由git跟踪。</p>
</blockquote>
<h4 id="5-1-新建仓库"><a href="#5-1-新建仓库" class="headerlink" title="5.1 新建仓库"></a>5.1 新建仓库</h4><blockquote>
<p>选择一个目录，执行指令：<a href="">git init</a></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">新建仓库</th>
<th align="center">仓库目录</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143314450-1391681047.png" alt="image-20231118143314616"></td>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143325501-711159843.png" alt="image-20231118143325822"></td>
</tr>
</tbody></table>
<h4 id="5-2-工作区"><a href="#5-2-工作区" class="headerlink" title="5.2 工作区"></a>5.2 工作区</h4><blockquote>
<p>执行<a href="">git init</a>的目录即为工作区，如上例，<a href="">D:\repo1</a>目录即为工作区【不包含<a href="">.git</a>目录】</p>
</blockquote>
<blockquote>
<p>所有文件，都首先在工作区新建，然后可以存入仓库(版本库)，进行版本控制。</p>
</blockquote>
<h4 id="5-3-暂存区"><a href="#5-3-暂存区" class="headerlink" title="5.3 暂存区"></a>5.3 暂存区</h4><blockquote>
<p>暂存区也在 <a href="">.git</a> 目录内，工作区的文件进入仓库时，要先进入暂存区。</p>
</blockquote>
<h4 id="5-4-分支"><a href="#5-4-分支" class="headerlink" title="5.4 分支"></a>5.4 分支</h4><blockquote>
<p>版本控制，简单说，就是记录文件的诸多版本，分支就是这些版本的最终记录位置。</p>
</blockquote>
<h3 id="六、基本操作"><a href="#六、基本操作" class="headerlink" title="六、基本操作"></a>六、基本操作</h3><hr>
<h4 id="6-1-查看仓库状态"><a href="#6-1-查看仓库状态" class="headerlink" title="6.1 查看仓库状态"></a>6.1 查看仓库状态</h4><blockquote>
<p>执行 <a href="">git  status</a> 可以看到工作区中文件的状态</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">未记录过的文件，是未跟踪状态</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143339822-1000730504.png" alt="image-20231118143339996"></td>
</tr>
</tbody></table>
<h4 id="6-2-暂存文件"><a href="#6-2-暂存文件" class="headerlink" title="6.2 暂存文件"></a>6.2 暂存文件</h4><blockquote>
<p>执行 <a href="">git add .</a> 将工作区中的文件全部<a href="">存入暂存区</a></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">将工作区中的文件存入暂存区</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143353117-1494446251.png" alt="image-20231118143353312"></td>
</tr>
</tbody></table>
<h4 id="6-3-提交文件"><a href="#6-3-提交文件" class="headerlink" title="6.3 提交文件"></a>6.3 提交文件</h4><blockquote>
<p>执行 <a href="">git commit -m “这里写提交的描述信息”</a> 作用是将暂存区的文件存入分支，形成一个版本</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">提交文件，形成一个版本</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143405386-1075167476.png" alt="image-20231118143405652"></td>
</tr>
</tbody></table>
<h3 id="七、远程仓库"><a href="#七、远程仓库" class="headerlink" title="七、远程仓库"></a>七、远程仓库</h3><hr>
<blockquote>
<p>第5章中的仓库，其实是本地仓库。</p>
<p>当多人协同开发时，每人都在自己的本地仓库维护版本。</p>
<p>但很重要的一点是，多人之间需要共享代码、合并代码，此时就需要一个<a href="">远程仓库</a>。</p>
</blockquote>
<h4 id="7-1-远程仓库工作模式"><a href="#7-1-远程仓库工作模式" class="headerlink" title="7.1 远程仓库工作模式"></a>7.1 远程仓库工作模式</h4><table>
<thead>
<tr>
<th align="center">远程仓库工作模式</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143432213-672457768.png" alt="image-20231118143432369"></td>
</tr>
</tbody></table>
<h4 id="7-2-远程仓库选型"><a href="#7-2-远程仓库选型" class="headerlink" title="7.2 远程仓库选型"></a>7.2 远程仓库选型</h4><blockquote>
<ul>
<li><p>有很多远程仓库可以选择，比如 github(<a target="_blank" rel="noopener" href="https://github.com/">https://github.com/</a>),码云(<a target="_blank" rel="noopener" href="https://gitee.com/">https://gitee.com/</a>)；</p>
<p> 此两种可以注册自己测试使用，但如果是商业项目，需要更多支持需要付费。</p>
</li>
<li><p>公司内部也可以有自己构建的远程仓库(<a target="_blank" rel="noopener" href="http://qianfeng.qfjava.cn:8087/users/sign_in">http://qianfeng.qfjava.cn:8087/users/sign_in</a>)。</p>
</li>
</ul>
</blockquote>
<h4 id="7-3-基本操作"><a href="#7-3-基本操作" class="headerlink" title="7.3 基本操作"></a>7.3 基本操作</h4><blockquote>
<p>每个开发人员，在面对远程仓库时，会面临的一些基本操作。</p>
</blockquote>
<h5 id="7-3-1-注册git服务器账号"><a href="#7-3-1-注册git服务器账号" class="headerlink" title="7.3.1 注册git服务器账号"></a>7.3.1 注册git服务器账号</h5><blockquote>
<p>在 <a target="_blank" rel="noopener" href="https://gitee.com/">码云</a> 注册账号，并登录。</p>
<p>进入公司后，很可能会使用公司自己搭建的git服务器，则账号向领导索要即可</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">点击注册，完成注册过程</th>
<th align="center"></th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143445731-1150239316.png" alt="image-20231118143446024"></td>
<td align="center"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">登录后显示主页</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143454963-1648476417.png" alt="image-20231118143455176"></td>
</tr>
</tbody></table>
<h5 id="7-3-2-新建远程仓库"><a href="#7-3-2-新建远程仓库" class="headerlink" title="7.3.2 新建远程仓库"></a>7.3.2 新建远程仓库</h5><table>
<thead>
<tr>
<th align="center">创建远程私有仓库-01</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143507151-1782049653.png" alt="image-20231118143507432"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">创建远程私有仓库-02</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143522420-251528464.png" alt="image-20231118143522580"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">创建远程私有仓库-03</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143544560-1907469803.png" alt="image-20231118143544615"></td>
</tr>
</tbody></table>
<h5 id="7-3-3-本地关联远程仓库"><a href="#7-3-3-本地关联远程仓库" class="headerlink" title="7.3.3 本地关联远程仓库"></a>7.3.3 本地关联远程仓库</h5><blockquote>
<p>本文档中选用仓库的 https协议的地址，将此地址关联到本地git中</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">如此后，本地即可用“origin” 代指远程仓库</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143559478-2029771024.png" alt="image-20231118143559692"></td>
</tr>
</tbody></table>
<h5 id="7-3-4-推送文件到远程仓库"><a href="#7-3-4-推送文件到远程仓库" class="headerlink" title="7.3.4 推送文件到远程仓库"></a>7.3.4 推送文件到远程仓库</h5><blockquote>
<p>将本地仓库中已经commit的内容push到远程仓库，以共享自己的代码。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">push</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143611832-385341346.png" alt="image-20231118143611899"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">输入凭证，如此码云才能接受此次上传的内容</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143619342-1220170260.png" alt="image-20231118143619627"></td>
</tr>
</tbody></table>
<h5 id="7-3-5-克隆远程仓库"><a href="#7-3-5-克隆远程仓库" class="headerlink" title="7.3.5 克隆远程仓库"></a>7.3.5 克隆远程仓库</h5><blockquote>
<p>如果仓库已经由别人创建完毕，我们需要其中的内容，则可以通过 <a href="">git clone</a> 将其复制到本地。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">新建目录“repo2”，然后在其中执行 git clone</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143631629-1109707034.png" alt="image-20231118143631870"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">远程仓库，复制到本地，并自动初始化为一个本地仓库</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143640754-1026926648.png" alt="image-20231118143641007"></td>
</tr>
</tbody></table>
<h5 id="7-3-6-代码共享"><a href="#7-3-6-代码共享" class="headerlink" title="7.3.6 代码共享"></a>7.3.6 代码共享</h5><blockquote>
<p>多人协同开发时，写好代码的<a href="">git push</a> 上传到远程仓库；需要代码的 <a href="">git pull</a> 拉取代码即可。 </p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">有人再次将本地仓库内容，上传到了远程仓库</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143656532-1079550092.png" alt="image-20231118143656646"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">重点：此时另一方如果想获得更新，则需要做一次拉取 git pull</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143717784-116025964.png" alt="image-20231118143717839"></td>
</tr>
</tbody></table>
<h5 id="7-3-7-命令汇总"><a href="#7-3-7-命令汇总" class="headerlink" title="7.3.7 命令汇总"></a>7.3.7 命令汇总</h5><table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>git   remote   add  标识名(master)  远程地址</td>
<td>本地关联远程仓库</td>
</tr>
<tr>
<td>git   push  标识名  master</td>
<td>将本地仓库内容上传到远程仓库</td>
</tr>
<tr>
<td>git   pull  标识名   master</td>
<td>从远程仓库下载内容到本地仓库</td>
</tr>
<tr>
<td>git   clone  远程地址</td>
<td>将远程仓库复制到本地，并自动形成一个本地仓库</td>
</tr>
</tbody></table>
<h3 id="八、分支"><a href="#八、分支" class="headerlink" title="八、分支"></a>八、分支</h3><hr>
<h4 id="8-1-分支简介"><a href="#8-1-分支简介" class="headerlink" title="8.1 分支简介"></a>8.1 分支简介</h4><blockquote>
<ul>
<li><p>分支，是一个个版本最终存储的位置。</p>
</li>
<li><p>分支，就是一条时间线，每次<a href="">git commit</a>形成一个个版本，一个个版本依次存储在分支的一个个提交点上。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">分支由多个提交点组成，分支上会有一个指针，默认总是指向最新的提交点</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143731726-714202560.png" alt="image-20231118143732008"></td>
</tr>
</tbody></table>
<h4 id="8-2-分支操作"><a href="#8-2-分支操作" class="headerlink" title="8.2 分支操作"></a>8.2 分支操作</h4><h5 id="8-2-1-查看分支"><a href="#8-2-1-查看分支" class="headerlink" title="8.2.1 查看分支"></a>8.2.1 查看分支</h5><blockquote>
<ul>
<li><p>查看当前仓库的分支 <a href="">git branch</a></p>
</li>
<li><p>仓库中默认只有 master 分支</p>
</li>
<li><p>执行<a href="">git commit</a>时，默认是在master分支上保存版本。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">默认只有master分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143742537-332084392.png" alt="image-20231118143742800"></td>
</tr>
</tbody></table>
<h5 id="8-2-2-创建分支"><a href="#8-2-2-创建分支" class="headerlink" title="8.2.2 创建分支"></a>8.2.2 创建分支</h5><blockquote>
<ul>
<li><p>在商业项目开发过程中，我们不会轻易的在<a href="">master</a>分支上做操作。</p>
</li>
<li><p>我们会新建一个<a href="">开发用的分支</a>，在此分支上做版本的记录。</p>
<p>当代码确实没有问题时，才会将开发分支上成熟的代码版本添加到<a href="">master</a>分支上。</p>
</li>
<li><p>保证开发过程中，可以及时记录版本，又保证<a href="">master</a>分支上每个提交点都是稳健版本。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">创建分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143754848-957556736.png" alt="image-20231118143755022"></td>
</tr>
</tbody></table>
<h5 id="8-2-3-切换分支"><a href="#8-2-3-切换分支" class="headerlink" title="8.2.3 切换分支"></a>8.2.3 切换分支</h5><blockquote>
<ul>
<li><p>默认情况下，当前使用的分支是 master分支</p>
</li>
<li><p>可以切换到 dev分支，则后续的<a href="">git commit</a> 便会在dev分支上新建版本(提交点)</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">切换分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143804217-1900571447.png" alt="image-20231118143804500"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">再次查看分支情况</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143825025-689730459.png" alt="image-20231118143825278"></td>
</tr>
</tbody></table>
<h4 id="8-3-新建分支细节"><a href="#8-3-新建分支细节" class="headerlink" title="8.3 新建分支细节"></a>8.3 新建分支细节</h4><blockquote>
<p>新建分支时，新分支，默认有哪些内容？分支中包含了哪些次提交？</p>
</blockquote>
<h5 id="8-3-1-新分支初始内容"><a href="#8-3-1-新分支初始内容" class="headerlink" title="8.3.1 新分支初始内容"></a>8.3.1 新分支初始内容</h5><blockquote>
<p>每个分支都有一个<a href="">指针</a>，新建一个分支，首先是新建一个<a href="">指针</a>。</p>
<p>而且新分支的指针会和当前分支指向<a href="">同一个提交点</a>。</p>
<p>新分支包含的提交点就是从第一个提交点到分支指针指向的提交点。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">每个分支都有一个指针，新建一个分支，首先是新建一个指针</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143834749-218331524.png" alt="image-20231118143834977"></td>
</tr>
</tbody></table>
<h5 id="8-3-2-多分支走向"><a href="#8-3-2-多分支走向" class="headerlink" title="8.3.2 多分支走向"></a>8.3.2 多分支走向</h5><blockquote>
<p>在master分支和新分支，分别进行 <a href="">git add</a> 和 <a href="">git commit</a></p>
<p>分支情况如下图：</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">master分支未动，在dev分支增加一次commit</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143844729-1685646913.png" alt="image-20231118143844920"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">master分支增加一个commit，dev分支再增加一个commit</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143853761-2100266460.png" alt="image-20231118143854036"></td>
</tr>
</tbody></table>
<h5 id="8-3-3-分支提交日志"><a href="#8-3-3-分支提交日志" class="headerlink" title="8.3.3 分支提交日志"></a>8.3.3 分支提交日志</h5><blockquote>
<p>查看分支的提交日志，进而看到分支中提交点的详细情况。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">提交情况如下</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143903270-1996358778.png" alt="image-20231118143903443"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">查看当前分支的提交日志</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143914236-1573204487.png" alt="image-20231118143914437"></td>
</tr>
</tbody></table>
<h4 id="8-4-分支合并"><a href="#8-4-分支合并" class="headerlink" title="8.4 分支合并"></a>8.4 分支合并</h4><blockquote>
<p>两个分支内容的合并</p>
</blockquote>
<blockquote>
<p><a href="">git merge 分支a</a>  合并分支a</p>
</blockquote>
<blockquote>
<p>合并的方式有两种：快速合并 和  三方合并。</p>
</blockquote>
<h5 id="8-4-1-快速合并"><a href="#8-4-1-快速合并" class="headerlink" title="8.4.1 快速合并"></a>8.4.1 快速合并</h5><blockquote>
<p>如果分支A当前的修改，是完全基于分支B的修改而来，则B分支合并A分支，就是移动指针即可。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">合并前分支状态</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143925643-969778620.png" alt="image-20231118143925883"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">快速合并效果（master 合并 dev）</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143935005-1043958158.png" alt="image-20231118143935281"></td>
</tr>
</tbody></table>
<h5 id="8-4-2-三方合并"><a href="#8-4-2-三方合并" class="headerlink" title="8.4.2 三方合并"></a>8.4.2 三方合并</h5><blockquote>
<p>在不具备快速合并的条件下，会采用三方合并。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">合并前，分支状态</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143943357-1762914460.png" alt="image-20231118143943601"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">三方合并，将<code>2</code>和<code>3</code>的更改都累加在<code>1</code>上，形成新的提交点</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118143952957-919511155.png" alt="image-20231118143953218"></td>
</tr>
</tbody></table>
<blockquote>
<p>三方合并,它是把两个分支的最新快照（2 和 3）以及二者最近的共同祖先（1）进行三方合并，合并的结果是生成一个新的快照（并提交）</p>
</blockquote>
<h5 id="8-4-3-合并冲突"><a href="#8-4-3-合并冲突" class="headerlink" title="8.4.3 合并冲突"></a>8.4.3 合并冲突</h5><blockquote>
<p>两个分支进行合并，但它们含有对同一个文件的修改，则在合并时出现冲突，git无法决断该保留改文件哪个分支的修改。</p>
</blockquote>
<h6 id="8-4-3-1-冲突演示"><a href="#8-4-3-1-冲突演示" class="headerlink" title="8.4.3.1 冲突演示"></a>8.4.3.1 冲突演示</h6><blockquote>
<p>场景模拟如下：</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">master分支修改hig.txt文件</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144006702-745001772.png" alt="image-20231118144006786"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">dev分支修改hig.txt</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144015375-1657289655.png" alt="image-20231118144015573"></td>
</tr>
</tbody></table>
<blockquote>
<p>在master分支 合并 dev分支</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">合并dev分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144026872-143489176.png" alt="image-20231118144027122"></td>
</tr>
</tbody></table>
<blockquote>
<p>此时，打开hig.txt 文件：</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">冲突后，git会将两个分支的内容都展示在文件中</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144036387-1048232826.png" alt="image-20231118144036653"></td>
</tr>
</tbody></table>
<h6 id="8-4-3-2-冲突解决"><a href="#8-4-3-2-冲突解决" class="headerlink" title="8.4.3.2 冲突解决"></a>8.4.3.2 冲突解决</h6><blockquote>
<p>出现冲突后，如要由两个开发人员当面协商，该如何取舍，为冲突文件定义最终内容。</p>
<p>解决方案：</p>
<ol>
<li>保留某一方的，删除另一方的</li>
<li>保留双方的</li>
<li>但无论如何，要记得删除  <a href="">&lt;&lt;&lt;&lt;  &#x3D;&#x3D;&#x3D;&#x3D;  &gt;&gt;&gt;&gt;</a> 这些</li>
<li>本质是两人协商为冲突的内容，定制出合理的内容。</li>
</ol>
</blockquote>
<table>
<thead>
<tr>
<th align="center">根据协商，再次编辑文件</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144045018-327103143.png" alt="image-20231118144045314"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">提交 再次编辑后的文件</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144052315-1857104333.png" alt="image-20231118144052541"></td>
</tr>
</tbody></table>
<h3 id="九、Idea关联Git"><a href="#九、Idea关联Git" class="headerlink" title="九、Idea关联Git"></a>九、Idea关联Git</h3><hr>
<h4 id="9-1-关联Git"><a href="#9-1-关联Git" class="headerlink" title="9.1 关联Git"></a>9.1 关联Git</h4><blockquote>
<p><a href="">File &gt; Settings</a>  关联过程是自动的</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">此处关联是Idea可以自动完成的</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144102276-1322951384.png" alt="image-20231118144102453"></td>
</tr>
</tbody></table>
<h4 id="9-2-创建仓库"><a href="#9-2-创建仓库" class="headerlink" title="9.2 创建仓库"></a>9.2 创建仓库</h4><blockquote>
<ul>
<li><p>新建项目后，将项目目录创建为git仓库</p>
</li>
<li><p>注意： 要在建仓库前，设置<a href="">忽略文件 “.gitignore”</a></p>
<p>作用：被忽略的文件会被版本记录忽略，版本中不包含它们。</p>
<p>范围：不需要和其他开发共享的文件，具体见下图。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">创建仓库前，先添加忽略文件</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144114639-1865611775.png" alt="image-20231118144114831"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">将项目目录初始化为一个仓库</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144127524-757573136.png" alt="image-20231118144127703"></td>
</tr>
<tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144138727-831760856.png" alt="image-20231118144138949"></td>
</tr>
</tbody></table>
<h4 id="9-3-提交-commit"><a href="#9-3-提交-commit" class="headerlink" title="9.3 提交-commit"></a>9.3 提交-commit</h4><blockquote>
<p>创建好仓库后，做第一次提交。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">选择提交菜单</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144148240-2083438892.png" alt="image-20231118144148478"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">选择提交文件，定义提交信息</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144159202-828407079.png" alt="image-20231118144159392"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">之后会有些友好提示，可以忽略，点击<code>“commit”</code>即可</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144221102-1985964648.png" alt="image-20231118144221350"></td>
</tr>
</tbody></table>
<h4 id="9-4-创建分支"><a href="#9-4-创建分支" class="headerlink" title="9.4 创建分支"></a>9.4 创建分支</h4><blockquote>
<p>新建开发分支</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">点击右下角链接，即可</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144234827-1002888359.png" alt="image-20231118144235117"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">新建分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144245538-757811888.png" alt="image-20231118144245774"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">查看当前分支</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144254918-773075157.png" alt="image-20231118144255200"></td>
</tr>
</tbody></table>
<h4 id="9-5-上传到远程仓库-push"><a href="#9-5-上传到远程仓库-push" class="headerlink" title="9.5 上传到远程仓库(push)"></a>9.5 上传到远程仓库(push)</h4><blockquote>
<ul>
<li><p>请首先参照第7章，创建一个远程仓库。</p>
</li>
<li><p>要求是裸库，且建议库名和项目名同名。</p>
</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th align="center">选择<code>push</code>菜单</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144306655-424837620.png" alt="image-20231118144306707"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">定义远程仓库地址</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144317202-300046318.png" alt="image-20231118144317457"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">执行，push操作</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144325365-236094702.png" alt="image-20231118144325553"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">push成功后 ，弹窗提示</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144338788-1427910688.png" alt="image-20231118144339015"></td>
</tr>
</tbody></table>
<h4 id="9-6-复制到本地仓库-clone"><a href="#9-6-复制到本地仓库-clone" class="headerlink" title="9.6 复制到本地仓库(clone)"></a>9.6 复制到本地仓库(clone)</h4><blockquote>
<p>如果有建好的远程仓库，比如公司内已经在用的仓库，或者github，码云上的一些公开仓库，</p>
<p>可以将远程仓库的项目复制到本地使用。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">点击克隆菜单</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144349025-1428039724.png" alt="image-20231118144349039"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">输入如远程仓库地址</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144357535-1083350856.png" alt="image-20231118144357724"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">打开项目</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144406040-1306685056.png" alt="image-20231118144406209"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">打开项目，选项</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144418593-293642869.png" alt="image-20231118144418880"></td>
</tr>
</tbody></table>
<h4 id="9-7-更新本地项目"><a href="#9-7-更新本地项目" class="headerlink" title="9.7 更新本地项目"></a>9.7 更新本地项目</h4><blockquote>
<p>如果远程仓库有更新，则你的本地项目也需要一起更新。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">选择pull菜单</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144431806-432832249.png" alt="image-20231118144431994"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">执行 pull操作</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144442620-1316725797.png" alt="image-20231118144442863"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">更新日志显示</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144450713-2041852087.png" alt="image-20231118144450831"></td>
</tr>
</tbody></table>
<h4 id="9-8-冲突解决"><a href="#9-8-冲突解决" class="headerlink" title="9.8 冲突解决"></a>9.8 冲突解决</h4><blockquote>
<p>合并分支时，如果出现冲突，则需要解决冲突。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">冲突出现，弹窗中可以选择如下</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144502121-1922182008.png" alt="image-20231118144502253"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">也可以直接修改冲突文件，然后commit即可</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144510394-2088787457.png" alt="image-20231118144510675"></td>
</tr>
</tbody></table>
<h3 id="十、多人协同开发"><a href="#十、多人协同开发" class="headerlink" title="十、多人协同开发"></a>十、多人协同开发</h3><hr>
<blockquote>
<p>多人开发协同，git操作</p>
</blockquote>
<h4 id="10-1-项目管理员-项目经理"><a href="#10-1-项目管理员-项目经理" class="headerlink" title="10.1 项目管理员( 项目经理 )"></a>10.1 项目管理员( 项目经理 )</h4><blockquote>
<p>1&gt; 由管理员负责创建一个远程库，初始的库中什么也没有，为裸库。库的名称建议和项目同名</p>
</blockquote>
<blockquote>
<p>2&gt; 管理员会在idea中创建一个初始项目,其中包含.gitignore文件。                                                                                          	 并在项目根目录下 建立本地库。并建立 dev分支。</p>
</blockquote>
<blockquote>
<p>3&gt; 管理员将本地库上传到远程库</p>
</blockquote>
<blockquote>
<p>4&gt; 将其他开发人员拉入远程库的 <a href="">开发成员列表中</a> ，使得其他开发人员可以访问该远程库。</p>
<p>流程如下：</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">点击添加成员</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231117174343518-1649653212.jpg" alt="添加开发成员"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">选择直接添加</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231117174419353-504100498.jpg" alt="添加开发成员2"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">提交</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144522067-221438997.png" alt="image-20231118144522350"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">查看已添加的开发成员</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144530181-1345299533.png" alt="image-20231118144530320"></td>
</tr>
</tbody></table>
<blockquote>
<p>5&gt; master分支设置为 <a href="">protected分支</a>，只有管理员有权限将代码合并到其中。dev分支设置为 <a href="">常规分支</a>所有开发人员 都可以其中合并代码</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">进入分支设置</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144538253-1478156974.png" alt="image-20231118144538428"></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">设置保护分支，让master分支不能被随更改</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144545130-945317719.png" alt="image-20231118144545311"></td>
</tr>
</tbody></table>
<h4 id="10-2-开发人员"><a href="#10-2-开发人员" class="headerlink" title="10.2 开发人员"></a>10.2 开发人员</h4><blockquote>
<ul>
<li><p>初始化：在idea中clone 远程库，获得项目。会建立本地库</p>
</li>
<li><p>后续的开发中，都要在dev分支上进行。开发完一个功能并测试通过后就commit 	 提交到本地的dev分支中，然后 上传(push)到远程dev分支中。	</p>
</li>
<li><p>需要更新项目内容时，通过 pull 从远程仓库拉取内容。																   	</p>
</li>
<li><p>注意：多人协同时，每次在 push 到远程库前，都先做一次pull，一来是把远程最新内容合并到本地，二来是核实本地内容是否和远程内容有冲突。</p>
</li>
<li><p>后续的开发，会接到一个个的功能任务，往复操作 2&gt;、3&gt;、4&gt; 而已。</p>
</li>
</ul>
</blockquote>
<h3 id="十一、经典问题"><a href="#十一、经典问题" class="headerlink" title="十一、经典问题"></a>十一、经典问题</h3><hr>
<blockquote>
<p>在使用https协议做push时，如果曾经使用过码云，但密码有过改动，此时会报错</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">使用https协议报错</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144556070-402910135.png" alt="image-20231118144556356"></td>
</tr>
</tbody></table>
<blockquote>
<p>解决方案:  <a href="">控制面板  》 凭据管理器 》</a> 删除对应凭证，再次使用时会提示重新输入密码。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">删除之前的码云凭证，然后重新push即可</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://img2023.cnblogs.com/blog/2233039/202311/2233039-20231118144603377-2004414503.png" alt="image-20231118144603568"></td>
</tr>
</tbody></table>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          Donate
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>Copyright： </strong>
          
          Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://example.com/2022/01/22/Git%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Git/" rel="tag">Git</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2022/01/22/Gitignore%20%E9%85%8D%E7%BD%AE%E8%AF%AD%E6%B3%95/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Gitignore 配置语法
          
        </div>
      </a>
    
    
      <a href="/2022/01/22/DNS%E8%AE%B0%E5%BD%95%E7%B1%BB%E5%9E%8B%E8%AF%A6%E8%A7%A3/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">DNS记录类型详解</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.staticfile.org/valine/1.4.16/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "dx3B54wOwhi75vxC2IAZagtg-gzGzoHsz",
    app_key: "m4k2fhnFa1iPI4vbofHqMY5X",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
  
   
    <script src="https://cdn.staticfile.org/twikoo/1.4.18/twikoo.all.min.js"></script>
    <div id="twikoo" class="twikoo"></div>
    <script>
        twikoo.init({
            envId: ""
        })
    </script>
 
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023
        <i class="ri-heart-fill heart_icon"></i> Shiguang
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="時光"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>